package com.yilin.medical.http;

import android.content.Context;

import com.yilin.medical.utils.AbBase64RequestParams;
import com.yilin.medical.utils.JxDeviceUtil;
import com.yilin.medical.utils.JxLogUtil;
import com.yilin.medical.utils.JxStringUtils;
import com.yilin.medical.utils.PushUtil;

public class HttpApi {

	private static final String TAG = "HttpApi";

	private Context mContext;

	private static HttpApi instance = null;

	private JxHttpUtil mJxHttpUtil = null;

	public static final String HTTP_SERVER_PREFIX = "http://192.168.2.193:441/"; // 内网测试服务器
	// public static final String HTTP_SERVER_PREFIX =
	// "http://192.168.2.193:441/"; //外网服务器
	public final static String HTTP_BASE_URL = JxGlobalConst.HTTP_URL_INTER;

	private final static String PATH_USER_LOGIN_OUT = HttpApi.HTTP_BASE_URL
			+ "user/logout";
	private final static String PATH_USER_LOGIN = HttpApi.HTTP_BASE_URL
			+ "user/login";
	private final static String PATH_USER_SMS_LOGIN = HttpApi.HTTP_BASE_URL
			+ "user/sms_login";
	private final static String PATH_USER_REGISTER = HttpApi.HTTP_BASE_URL
			+ "user/register";
	private final static String PATH_USER_ENTRUST = HttpApi.HTTP_BASE_URL
			+ "entrust/add";
	private final static String PATH_USER_MESSAGE = HttpApi.HTTP_BASE_URL
			+ "common/sms/sendCode";
	private final static String PATH_USER_ENTRUSTINFO = HttpApi.HTTP_BASE_URL
			+ "entrust/my/";
	private final static String PATH_USER_CHANGEPASSWD = HttpApi.HTTP_BASE_URL
			+ "find/changepasswd";
	private final static String PATH_USER_CHANGE_PASSWORD = HttpApi.HTTP_BASE_URL
			+ "user/changepasswd";
    private final static String PATH_USER_SET_PASSWORD = HttpApi.HTTP_BASE_URL
			+ "user/set_newpwd";
    private final static String PATH_USER_UPDATE_USERINFO = HttpApi.HTTP_BASE_URL
			+ "user/changedisplayname";
    private final static String PATH_USER_VALID_EMAIL = HttpApi.HTTP_BASE_URL
			+ "user/valid_email";
    private final static String PATH_FAVORITE_VERIFY_MORE = HttpApi.HTTP_BASE_URL
			+ "favorite/verify_more";
	private final static String PATH_USER_CHANGE_USER_HEAD = HttpApi.HTTP_BASE_URL
			+ "user/changepic";
	private final static String PATH_USER_CHANGE_LOGIN_NAME = HttpApi.HTTP_BASE_URL
			+ "user/changeloginname";
    private final static String PATH_USER_CHANGE_USER_NAME = HttpApi.HTTP_BASE_URL
			+ "user/changedisplayname";
	private final static String PATH_USER_GET_USER_INFOR = HttpApi.HTTP_BASE_URL
			+ "user/read";
	private final static String PATH_USER_GET_USER_BROWS_HISTORY = HttpApi.HTTP_BASE_URL
			+ "browse/my_browse";

	private final static String PATH_USER_GET_USER_MY_ATTENTION = HttpApi.HTTP_BASE_URL
			+ "favorite/my";
	private final static String PATH_USER_GET_USER_MY_ATTENTION_UNLOGIN = HttpApi.HTTP_BASE_URL
			+ "favorite/device_my";
    private final static String PATH_USER_GET_USER_MY_ATTENTION_COGRADIENT = HttpApi.HTTP_BASE_URL
			+ "favorite/cogradient";

	private final static String PATH_USER_GET_USER_CALL_RECORDS = HttpApi.HTTP_BASE_URL
			+ "telephone/my";
    private final static String PATH_USER_DELETE_ONE_CALL_RECORDS = HttpApi.HTTP_BASE_URL
			+ "telephone/cancel";
    private final static String PATH_USER_DELETE_ALL_CALL_RECORDS = HttpApi.HTTP_BASE_URL
			+ "telephone/cancel_all";
	private final static String PATH_DELETE_ONE_BROWS_HISTORY = HttpApi.HTTP_BASE_URL
			+ "browse/cancel";

	private final static String PATH_DELETE_ALL_BROWS_HISTORY = HttpApi.HTTP_BASE_URL
			+ "browse/cancel_all";

	private final static String PATH_DELETE_ALL_ATTENTION = HttpApi.HTTP_BASE_URL
			+ "favorite/cancel_all";

	private final static String PATH_DELETE_ONE_ATTENTION = HttpApi.HTTP_BASE_URL
			+ "favorite/cancel";

	private final static String PATH_USER_FEED_BACK = HttpApi.HTTP_BASE_URL
			+ "user/feedback";
	private final static String PATH_USER_FEEDBACK_READ = HttpApi.HTTP_BASE_URL
			+ "user/feedback_read";

	private final static String PATH_DELETE_ONE_SEARCH_HISTORY = HttpApi.HTTP_BASE_URL
			+ "history/login_user_cancel";
	// 推送开关
	private final static String PATH_USER_IS_NOTICE = HttpApi.HTTP_BASE_URL
			+ "baidu/isnotice";
	private final static String PATH_USER_VERSION_UPDATING = HttpApi.HTTP_BASE_URL
			+ "baidu/android_version_change/android_";
	public static final String HTTP_URL_NEWENTRUST = "http://apidev.51zhagen.com/";// 委托跟路径
	private final static String PATH_USER_NEWENTRUST = HttpApi.HTTP_BASE_URL
			+ "entrust/add";
    private final static String GET_HOUSE_THUMB = HttpApi.HTTP_BASE_URL
			+ "image/get_house_thumb";
    private final static String PATH_BESPEAK_ADD = HttpApi.HTTP_BASE_URL
			+ "bespeak/add";
    private final static String PATH_BESPEAK_EVALUATE = HttpApi.HTTP_BASE_URL
			+ "bespeak/evaluate";
    private final static String PATH_BESPEAK_VERIFY = HttpApi.HTTP_BASE_URL
			+ "bespeak/verify_bespeak";
    private final static String PATH_AD_RESULT = HttpApi.HTTP_BASE_URL+"image/advertisement";
    private final static String PATH_ONE_AD_RESULT = HttpApi.HTTP_BASE_URL+"image/focus_thumb";
    private final static String REPORT_RESULT = HttpApi.HTTP_BASE_URL+"report/add";

    private final static String PATH_ERSHOUFANG_DETAIL = HttpApi.HTTP_BASE_URL
            + "ershoufang/ershoufang_detail";
    private final static String PATH_RENTHOUSE_DETAIL = HttpApi.HTTP_BASE_URL
            + "renthouse/detail";

	private HttpApi(Context context) {
		this.mContext = context;
		// 获取Http工具类
		mJxHttpUtil = JxHttpUtil.getInstance(mContext);
		mJxHttpUtil.setDebug(false);
		mJxHttpUtil.setTimeout(15000);
	}

	/**
	 * 描述：获取实例.
	 *
	 * @param context
	 *            the context
	 * @return single instance of HttpApi
	 */
	public static HttpApi getInstance(Context context) {
		if (null == instance) {
			instance = new HttpApi(context);
		}

		return instance;
	}

	/**
	 * 登录接口 get
	 *
	 * @param phone
	 *            手机号
	 * @param pass
	 *            密码
	 */
//
//	public void doLoginGet(String phone, String pass) {
//		String urlString = PATH_USER_LOGIN + "?phone=" + phone + "&pass="
//				+ pass + "";
//		mJxHttpUtil.get(urlString, new AbStringHttpResponseListener() {
//
//			// 获取数据成功会调用这里
//			@Override
//			public void onSuccess(int statusCode, String content) {
//				JxLogUtil.d(TAG, "onSuccess");
//			}
//
//			// 失败，调用
//			@Override
//			public void onFailure(int statusCode, String content,
//					Throwable error) {
//			}
//
//			// 开始执行前
//			@Override
//			public void onStart() {
//				JxLogUtil.d(TAG, "onStart");
//			}
//
//			// 完成后调用，失败，成功
//			@Override
//			public void onFinish() {
//				JxLogUtil.d(TAG, "onFinish");
//			};
//
//		});
//	}
//
	/**
	 * 登录接口 post
	 *
	 * @param phone
	 *            手机号
	 * @param pass
	 *            密码
	 */

	public void doLoginPost(Context context, String phone, String pass,
			JxHttpResponseListener listener) {
		// 绑定参数
		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("mobile", phone);
		params.put("password", pass);
		params.put("device_id", JxDeviceUtil.getDeviceId(context));
		params.put("devicetype", "1");
		params.put("baiduuserid", PushUtil.getPushUserId(context));
		params.put("baiduchannelid", PushUtil.getPushChannelId(context));
		mJxHttpUtil.post(PATH_USER_LOGIN, params, listener);
	}

    /**
     * 获取房源详情
     * @param type 1 二手房  2 租房
     * @param houseid
     * @param userid
     * @param listener
     */
    public void doGetHouseInfo(int type,String houseid,String userid,JxStringHttpResponseListener listener){
        String url = type==1?PATH_ERSHOUFANG_DETAIL:PATH_RENTHOUSE_DETAIL;
        url += "/"+houseid+"/"+userid;
        JxLogUtil.i("gmx",url);
        mJxHttpUtil.get(url, listener);
    }





//
	/**
	 * 短信登录接口 post
	 *
	 * @param phone
	 *            手机号
	 * @param code
	 *            验证码
	 */

	public void doSmsLoginPost(Context context, String phone, String code,
			JxHttpResponseListener listener) {
		// 绑定参数
		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("mobile", phone);
		params.put("code", code);
		params.put("device_id", JxDeviceUtil.getDeviceId(context));
		params.put("devicetype", "1");
		params.put("baiduuserid", PushUtil.getPushUserId(context));
		params.put("baiduchannelid", PushUtil.getPushChannelId(context));
		mJxHttpUtil.post(PATH_USER_SMS_LOGIN, params, listener);
	}

	/**
	 5.1 user/index/reg用户注册
		方法名称：user/index/reg
		接口类型：实时接口
		功能描述：用户注册
		HTTP请求方式：POST
		请求参数：
		变量名称	类型	描述
		username	Varchar(50)	用户名(手机)
		smscode	Varchar(10)	短信验证码
		password	Varchar(16)	密码
		name	varchar(20)	姓名 
		sortchar	char(1)	姓名首字母 
		sex 	tinyint(1)	性别(0 女,1 男) 
		position 	int(11)	职位ID 
		professon 	int(11)	职业ID 
		degree 	int(11)	学历ID
		email 	varchar(50)	邮箱
		tel 	varchar(50)	固定电话
		area1 	int(11)	省ID
		area2 	int(11)	市ID
		area3 	int(11)	区县ID
		chooseHospital	int(11)	选择的医院ID 
		hospitalName 	varchar(50)	手动输入的医院名称 
		hospitalLevel 	int(11)	手动输入的医院等级ID 
		address 	varchar(100)	地址 
		zipCode 	varchar(6)	邮篇
		department 	int(11)	所在医院的科室ID 
		title 	int(11)	职称ID 
		
		
		返回结果：仅数据部分,主体结构见上
		参数名	类型	描述
		uid	int	用户ID
		
		JSON
		{
		　　"uid":"用户ID",
		}
	 */
	public void doRegisterPost(Context context, String phone, String pwd,
			String code, JxHttpResponseListener listener) {
		// 绑定参数
        JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("mobile", phone);
		params.put("password", pwd);
		params.put("devicetype", "1");
		params.put("mobilevcode", code);
		params.put("devicecode", JxDeviceUtil.getDeviceId(context));
		mJxHttpUtil.post(PATH_USER_REGISTER, params, listener);
	}

//	/**
//	 * 添加用户的委托房源
//	 *
//	 * @Request POST
//	 * @uri http://api.51zhagen.com/entrust/add mobile 用户手机号 user_name 用户姓名
//	 *      bd_id 区域id bbd_id 商圈id code 验证码 apikey 加密号 uid 用户id
//	 */
//	public void doEntrustPost(Context context, String phone, String username,
//			String bd_id, String bbd_id, String code, String apikey,
//			String uid, JxHttpResponseListener listener) {
//		// 绑定参数
//		/*
//		 * mobile 用户手机号 user_name 用户姓名 bd_id 区域id bbd_id 商圈id code 验证码
//		 */
//		JxBase64 params = new JxBase64();
//		params.put("mobile", phone);
//		params.put("user_name", username);
//		params.put("bd_id", bd_id);
//		params.put("bbd_id", bbd_id);
//		params.put("code", code);
//		params.put("apikey", apikey);
//		params.put("uid", uid);
//		mJxHttpUtil.post(PATH_USER_ENTRUST, params, listener);
//	}
//
	/**
	 * 获取验证码
	 *
	 * @param phone
	 * @param listener
	 */
	public void doGetCode(String phone, JxHttpResponseListener listener) {
		AbBase64RequestParams params = new AbBase64RequestParams();
		params.put("mobile", phone);
		mJxHttpUtil.post(PATH_USER_MESSAGE, params, listener);
	}

    /**
     * 我的委托房源列表
     * @Request GET
     * @uri    http://apidev.zhagen.com/2.0.0/entrust/my/$userid/$start/$end/$apikey
     * @access public
     * @param  int $userid       用户id
     * @param  string $apikey    加密码
     * @param  string $start     记录数开始  每次都会减1
     * @param  string $end       记录数 结束
     * @return json string
     */
	public void doGetEntrustInfo(String userid, String apikey, int start,
			int end, JxHttpResponseListener listener) {
		// AbBase64RequestParams params = new AbBase64RequestParams();
		// String url = PATH_USER_ENTRUSTINFO+"$userid/$start/$end/$apikey";
		String url = PATH_USER_ENTRUSTINFO + userid + "/" + start + "/" + end
				+ "/" + apikey;
        JxLogUtil.i("gmx   ==="+url);
		/*
		 * url.replace("userid", userid); url.replace("apikey", apikey);
		 * url.replace("start", start);F url.replace("$end", end);
		 */
		mJxHttpUtil.get(url, listener);
	}


//
//	public void doGetEntrustAdd(String mobile, String user_name, String bd_id,
//			String bbd_id, String code, String apikey, String uid,
//			String device_id, String devicetype, String baiduuserid,
//			String baiduchannelid, JxHttpResponseListener listener) {
//		JxBase64 params = new JxBase64();
//
//		params.put("mobile", mobile);
//		params.put("user_name", user_name);// 1 个人
//		params.put("bd_id", bd_id);// 1 个人
//		params.put("bbd_id", bbd_id);// 1 个人
//		params.put("code", code);// 1 个人
//		params.put("apikey", apikey);// 1 个人
//		params.put("uid", uid);// 1 个人
//		params.put("device_id", device_id);// 1 个人
//		params.put("devicetype", devicetype);// 1 个人
//		params.put("baiduuserid", baiduuserid);// 1 个人
//		params.put("baiduchannelid", baiduchannelid);// 1 个人
//		// System.out.println("ljq params="+params.toString());
//
//		mJxHttpUtil.post(PATH_USER_NEWENTRUST, params, listener);
//	}


    /**
     * 获取每个用户下所有的关注的接口
     * @Request POST
     * @uri    http://apidev.zhagen.com/2.0.0/favorite/verify_more
     * @access public
     * @param  int $userid          设备号
     * @param  string $apikey        加密码
     * @param  int    $type          1=房源 2=小区 3=租房
     * @return json string
     */
    public void getMyFavorites(String userid,String apikey,int type,JxHttpResponseListener listener){
        JxBase64RequestParams params = new JxBase64RequestParams();
        params.put("userid", userid);
        params.put("apikey", apikey);
        params.put("type", type+"");
        mJxHttpUtil.post(PATH_FAVORITE_VERIFY_MORE, params, listener);
    }

	/**
	 * 密码找回
	 *
	 * @param phone
	 * @param password
	 * @param mobilevcode
	 * @param listener
	 */
	public void doForgetPwdPost(String phone, String password,
			String mobilevcode, JxHttpResponseListener listener) {
		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("mobile", phone);
		params.put("password", password);
		params.put("repassword", password);
		params.put("mobilevcode", mobilevcode);
		mJxHttpUtil.post(PATH_USER_CHANGEPASSWD, params, listener);
	}

	/**
	 * 更改密码 post
	 *
	 * @param oldPassWord
	 * @param newPassWord
	 * @param listener
	 */
	public void changePassWord(String pwd, String password, String passwordf,
			String userid, String apikey, JxHttpResponseListener listener) {
		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("pwd", pwd);
		params.put("password", password);
		params.put("passwordf", passwordf);

		params.put("userid", userid);
		params.put("apikey", apikey);
		mJxHttpUtil.post(PATH_USER_CHANGE_PASSWORD, params, listener);

	}

    /**
     * 设置新密码
     * @request mode  POST
     * @uri    http://apidev.zhagen.com/2.0.0/user/set_newpwd
     * @access public
     * @param  string $userid    用户ID
     * @param  string $password  新密码
     * @param  string $mobile    手机号
     * @param  string $code      验证码
     * @param  string $apikey    加密码
     * @return json string
     */
    public void setPassWord(String password, String code,String mobile,
			String userid, String apikey, JxHttpResponseListener listener) {
		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("password", password);
		params.put("code", code);
		params.put("mobile", mobile);
		params.put("userid", userid);
		params.put("apikey", apikey);
		mJxHttpUtil.post(PATH_USER_SET_PASSWORD, params, listener);

	}

/*    *//**
     * 更新用户信息
     * @request mode  POST
     * @uri    http://apidev.zhagen.com/2.0.0/user/changedisplayname
     * @access public
     * @param  string $userid    用户ID
     * @param  string $displayname  昵称
     * @param  string $email        邮箱
     * @param  string $gender       性别 m 男 f 女
     * @param  string $birthdata    生日
     * @param  string $apikey
     * @return json string
     *//*
    public void updateUserInfo(UserInfo userInfo, JxHttpResponseListener listener) {
        JxBase64RequestParams params = new JxBase64RequestParams();
        params.put("displayname", userInfo.DISPLAY_NAME);
        params.put("email", userInfo.EMAIL);
        params.put("gender", userInfo.GENDER);
        params.put("birthdata", userInfo.BIRTHDATE);
        params.put("userid", userInfo.ID);
        params.put("apikey", userInfo.APIKEY);
        mJxHttpUtil.post(PATH_USER_UPDATE_USERINFO, params, listener);

    }
*/    /**
     * 检查用户邮箱是否存在
     * @request mode  POST
     * @uri    http://apidev.zhagen.com/2.0.0/user/valid_email
     * @access public
     * @param  string $userid    用户ID
     * @param  string $emall        邮箱
     * @return json string
     */
    public void validEmail(String userId, String email, JxHttpResponseListener listener) {
        JxBase64RequestParams params = new JxBase64RequestParams();
        params.put("userid", userId);
        params.put("email", email);
        mJxHttpUtil.post(PATH_USER_VALID_EMAIL, params, listener);

    }


    

//
//	/**
//	 * 更改头像 post
//	 *
//	 * @param headPath
//	 * @param userid
//	 * @param listener
//	 */
//	public void changeUserHead(File headPath, String userid, String apiKey,
//			JxHttpResponseListener listener) {
//
//		JxBase64 params = new JxBase64();
//		params.put("userid", userid);
//		params.put("photo_path", headPath);
//		params.put("apikey", apiKey);
//
//		mJxHttpUtil.post(PATH_USER_CHANGE_USER_HEAD, params, listener);
//
//	}
//
//	/**
//	 * 更改名字 post
//	 *
//	 * @param name
//	 * @param userid
//	 * @param listener
//	 */
//	public void changeUserName(String name, String userid, String apiKey,
//			JxHttpResponseListener listener) {
//
//		String id = JxBase64.encodeBase64String(userid);
//		String key = JxBase64.encodeBase64String(apiKey);
//
//		JxBase64 params = new JxBase64();
//		params.put("userid", userid);
//		params.put("login_name", name);
//		params.put("apikey", apiKey);
//
//		mJxHttpUtil.post(PATH_USER_CHANGE_LOGIN_NAME, params, listener);
//
//	}
//
//
//
//    /**
//     * 更改名字 post
//     *
//     * @param name
//     * @param userid
//     * @param listener
//     */
//    public void changeRealName(String name, String userid, String apiKey,
//                               JxHttpResponseListener listener) {
//
//        String id = JxBase64.encodeBase64String(userid);
//        String key = JxBase64.encodeBase64String(apiKey);
//
//        JxBase64 params = new JxBase64();
//        params.put("userid", userid);
//        params.put("displayname", name);
//        params.put("apikey", apiKey);
//
//        mJxHttpUtil.post(PATH_USER_CHANGE_USER_NAME, params, listener);
//
//    }
	/**
	 *
	 * 获取用户资料 get
	 *
	 * @param userid
	 * @param listener
	 */

	public void getUserInfor(String userid, JxHttpResponseListener listener) {
		String urlString = PATH_USER_GET_USER_INFOR + "?userid=" + userid + "";
		mJxHttpUtil.get(urlString, listener);

	}
//
//	/**
//	 *
//	 * 获取用户的浏览历史 get
//	 *
//	 * @param string
//	 *            start 记录数开始 每次都会减1
//	 * @param string
//	 *            end 记录数 结束
//	 * @param String
//	 *            userid 用户id
//	 * @param string
//	 *            apikey 加密码
//	 * @param String
//	 *            type 类型 0=全部 1=房源 2=小区 =3租房
//	 * @param listener
//	 */
//	public void getUserBrowsHistory(String start, String end, String userid,
//			String apiKey, int type, JxHttpResponseListener listener) {
//		String urlString = PATH_USER_GET_USER_BROWS_HISTORY + "/" + userid
//				+ "/" + start + "/" + end + "/" + apiKey + "/" + type;
//		// JxLogUtil.i(urlString);
//		mJxHttpUtil.get(urlString, listener);
//
//	}

	/**
	 *
	 * 我的关注 get
	 *
	 * @param start
	 * @param end
	 * @param userid
	 * @param listener
	 */
	public void getUserFavorites(String start, String end, String userid,
			String apiKey, int type, JxHttpResponseListener listener) {
		String urlString=null;
		if(userid==null){
			urlString = PATH_USER_GET_USER_MY_ATTENTION_UNLOGIN + "/" + JxDeviceUtil.getDeviceId(mContext) + "/"
					+ start + "/" + end + "/" + type + "";
		}else{
			urlString = PATH_USER_GET_USER_MY_ATTENTION + "/" + userid + "/"
					+ start + "/" + end + "/" + apiKey + "/" + type + "";
		}
		JxLogUtil.i("gmx:"+urlString);

		mJxHttpUtil.get(urlString, listener);

	}
//
//	/**
//	 * 我的通话记录记录
//	 *
//	 * @Request GET
//	 * @uri
//	 *      http://apidev.zhagen.com/telephone/my/$userid/$start/$end/$apikey/$type
//	 * @access public
//	 * @param int $userid 用户id
//	 * @param string
//	 *            $apikey 加密码
//	 * @param string
//	 *            $start 记录数开始 每次都会减1
//	 * @param string
//	 *            $end 记录数 结束
//	 * @param int $type 类型 1=房源 2=小区 =3租房
//	 * @return json string
//	 */
//	public void getUserCallRecords(String start, String end, String userid,
//			String apiKey, int type, JxHttpResponseListener listener) {
//		String urlString = PATH_USER_GET_USER_CALL_RECORDS + "/" + userid + "/"
//				+ start + "/" + end + "/" + apiKey + "/" + type + "";
//		JxLogUtil.i(urlString);
//		mJxHttpUtil.get(urlString, listener);
//
//	}
//
//	/**
//	 *
//	 * 删除某个历史记录 post
//	 *
//	 * @param deviceCode
//	 * @param id
//	 * @param listener
//	 */
//	public void deleteOneBrowsHistory(String id, String userId, String apiKey,
//			JxHttpResponseListener listener) {
//
//		JxBase64 params = new JxBase64();
//		params.put("id", id);
//		params.put("userid", userId);
//		params.put("apikey", apiKey);
//
//		mJxHttpUtil.post(PATH_DELETE_ONE_BROWS_HISTORY, params, listener);
//
//	}
//
//    /**
//     * 同步数据 将设备号下关注的同步到用户下   TODO
//     * @Request POST
//     * @uri    http://apidev.zhagen.com/favorite/cogradient
//     * @access public
//     * @param  int $userid         用户id
//     * @param  string $apikey      加密码
//     *    string $device_id   设备号
//     * @return json string
//     */
//    public void doCogradient(String userId, String apiKey,
//			JxHttpResponseListener listener) {
//
//		JxBase64 params = new JxBase64();
//		params.put("device_id", JxDeviceUtil.getDeviceId(mContext));
//		params.put("userid", userId);
//		params.put("apikey", apiKey);
//		mJxHttpUtil.post(PATH_USER_GET_USER_MY_ATTENTION_COGRADIENT, params, listener);
//
//	}
//
//	/**
//	 *
//	 *
//	 * 清空所有的历史记录 post
//	 *
//	 * @param deviceCode
//	 * @param listener
//	 */
//	public void deleteAllBrowsHistory(String userId, String apikey,
//			String type, JxHttpResponseListener listener) {
//
//		JxBase64 params = new JxBase64();
//		params.put("userid", userId);
//		params.put("apikey", apikey);
//		params.put("type", type);
//
//		mJxHttpUtil.post(PATH_DELETE_ALL_BROWS_HISTORY, params, listener);
//
//	}
//
	public void deleteOneFavorites(String apiKey, String attentionId,
			String userId, int type, JxHttpResponseListener listener) {

		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("code", attentionId);
		params.put("userid", userId);
		params.put("apikey", apiKey);
		params.put("type", type + "");

		mJxHttpUtil.post(PATH_DELETE_ONE_ATTENTION, params, listener);

	}
//
//	/**
//	 *
//	 * 清空所有的关注 post
//	 *
//	 * @param deviceCode
//	 * @param listener
//	 */
//	public void deleteAllAttention(String userId, String apiKey, int type,
//			JxHttpResponseListener listener) {
//
//		JxBase64 params = new JxBase64();
//
//		params.put("userid", userId);
//		params.put("apikey", apiKey);
//		params.put("type", type + "");
//
//		mJxHttpUtil.post(PATH_DELETE_ALL_ATTENTION, params, listener);
//
//	}
//
//	/**
//	 *
//	 * 是否接受通知
//	 *
//	 * @param userId
//	 * @param apiKey
//	 * @param isreceive
//	 *            是否打开推送开关
//	 * @param listener
//	 */
//	public void isNotice(String userId, String apiKey, boolean isreceive,
//			JxHttpResponseListener listener) {
//		String isReceive = isreceive ? "1" : "0";
//		JxBase64 params = new JxBase64();
//		params.put("userid", userId);
//		params.put("apikey", apiKey);
//		params.put("isreceive", isReceive);
//		mJxHttpUtil.post(PATH_USER_IS_NOTICE, params, listener);
//
//	}
//
	/**
	 *
	 * 退出
	 *
	 * @param userId
	 * @param apiKey
	 * @param listener
	 */

	public void logOut(String userId, String apiKey,
			JxHttpResponseListener listener) {

		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("userid", userId);
		params.put("apikey", apiKey);
		mJxHttpUtil.post(PATH_USER_LOGIN_OUT, params, listener);

	}
	

	/**
	 * 反馈
	 *
	 * @param userid
	 * @param apikey
	 * @param content
	 * @param listener
	 */
	public void doFeedBackPost(Context context,String devicecode, String content,
			JxHttpResponseListener listener) {
		JxBase64RequestParams params = new JxBase64RequestParams();
		params.put("devicecode", devicecode);
		params.put("content", content);
		params.put("source", "3");
		params.put("baiduuserid", PushUtil.getPushUserId(context));
		params.put("baiduchannelid", PushUtil.getPushChannelId(context));
		mJxHttpUtil.post(PATH_USER_FEED_BACK, params, listener);
	}

	/**
	 * 获取反馈列表
	 *
	 * @param context
	 * @param userid
	 * @param apikey
	 * @param start
	 * @param end
	 * @param listener
	 */
	public void doFeedBackList(Context context, String devicecode,
			String start, String end, JxHttpResponseListener listener,String isPush) {
		StringBuilder builder = new StringBuilder();
		builder.append("/").append(devicecode).append("/").append(start)
				.append("/").append(end).append("/").append(isPush);
		JxLogUtil.v(JxLogUtil.JACK_TAG, "feedback url is :"+PATH_USER_FEEDBACK_READ + builder.toString());
		mJxHttpUtil.get(PATH_USER_FEEDBACK_READ + builder.toString(), listener);
	}

	/**
	 * 版本更新
	 *
	 * @param context
	 * @param listener
	 */
	/*public void doVersionUpdating(Context context,
			JxHttpResponseListener listener) {
		mJxHttpUtil.get(HttpApi.PATH_USER_VERSION_UPDATING
				+ context.getResources().getString(R.string.apk_version_name) + "/"
				+ context.getResources().getString(R.string.channel_id),
				listener);
	}
//
*///	public void deleteOneSearchHistory(String id, String deviceCode,
//			JxHttpResponseListener listener) {
//
//		JxBase64 params = new JxBase64();
//		params.put("id", id);
//		params.put("devicecode", deviceCode);
//
//		mJxHttpUtil.post(PATH_DELETE_ONE_SEARCH_HISTORY, params, listener);
//
//	}
//    /**
//     * 删除通话记录记录
//     * @Request POST
//     * @uri    http://apidev.zhagen.com/telephone/cancel
//     * @access public
//     * @param  int $id                     通话记录记录表id
//     * @param  int $userid          用户id
//     * @param  string $apikey        加密码
//     */
//    public void deleteOneCallRecords(String id,
//			JxHttpResponseListener listener) {
//		JxBase64 params = new JxBase64();
//		params.put("id", id);
//		params.put("userid", JxUserInfoUtil.getUserId(mContext));
//		params.put("apikey", JxUserInfoUtil.getAPIKEY(mContext));
//		mJxHttpUtil.post(PATH_USER_DELETE_ONE_CALL_RECORDS, params, listener);
//
//	}
//
//    /**
//     * 清空通话记录记录
//     * @Request POST
//     * @uri    http://apidev.zhagen.com/telephone/cancel_all
//     * @access public
//     * @param  int $userid          用户id
//     * @param  string $apikey        加密码
//     * @param  int $type   类型     0=全部1=房源 2=小区 =3租房
//     * @return json string
//     */
//    public void deleteALLCallRecords(int type,
//			JxHttpResponseListener listener) {
//		JxBase64 params = new JxBase64();
//		params.put("type", type+"");
//		params.put("userid", JxUserInfoUtil.getUserId(mContext));
//		params.put("apikey", JxUserInfoUtil.getAPIKEY(mContext));
//		mJxHttpUtil.post(PATH_USER_DELETE_ALL_CALL_RECORDS, params, listener);
//
//	}
//

    /**
     * 获取全景看房的图片
     * @Request GET
     * @uri    http://apidev.zhagen.com/image/get_house_thumb/$house_id/$house_type/$token
     * @param unknown $house_id     房源id
     * @param unknown $house_type   房源类型 1出售2出租
     * @param unknown $token        md5('zhagen')
     */
    public void getHouseThumb(String houseId,int type,JxHttpResponseListener listener){
        //GET_HOUSE_THUMB
        String urlString = GET_HOUSE_THUMB
                + "/" + houseId
                + "/" + type + "/"+ JxStringUtils.getMD5Str("zhagen");
        mJxHttpUtil.get(urlString, listener);
    }

//
//

    /**
     * 获取广告位结果
      * 方法描述
      * create: 2014-10-27下午5:16:50
      * @param model 参数描述
      * @return 返回值描述
     */
    public void getADResult(JxHttpResponseListener listener){
    	AbBase64RequestParams params = new AbBase64RequestParams();
    	params.put("device_type", "2");
    	mJxHttpUtil.post(PATH_AD_RESULT, params,listener);
    }
    
    public void getOneADResult(String id,JxHttpResponseListener listener){
    	mJxHttpUtil.get(PATH_ONE_AD_RESULT+"/"+id, listener);
    }
    
}
